package com.uenpay.oem;

import android.content.Context;
import android.support.multidex.MultiDex;

import com.alibaba.android.arouter.launcher.ARouter;
import com.socks.library.KLog;
import com.uenpay.im.IMApplication;
import com.uenpay.oem.data.bean.UserAuthInfo;
import com.uenpay.oem.net.HttpErrorHandler;
import com.uenpay.util.common.AppConfig;
import com.uenpay.util.common.AppConfigUtil;

import cn.sharesdk.framework.ShareSDK;

/**
 * Created by PS on 2016/11/14.
 */
public class MyApplication extends IMApplication {


    private MyApplication instance = null;
    private static Context context;

    private static UserAuthInfo mUserAuthInfo;
    private static String mBalance; //账户余额

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        context = getApplicationContext();
        AppConfigUtil.init(getApplicationContext());
//        HttpErrorHandler.regesiter();
        if (BuildConfig.DEBUG) {
            ARouter.openLog();     // 打印日志
            ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行，必须开启调试模式！线上版本需要关闭,否则有安全风险)
        }
        ARouter.init(this); // 尽可能早，推荐在Application中初始化
        KLog.init(BuildConfig.LOG_DEBUG, AppConfig.LOG_TAG);


//        ((BaseFakeApplication) (ARouter.getInstance().build("/application/im").navigation())).onLoad(this);
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        //解决在5.0机器下multiDexEnabled 保存问题
        //http://blog.csdn.net/sayid_des/article/details/50462261
        MultiDex.install(this);
    }

    public static UserAuthInfo getUserAuthInfo() {
        return mUserAuthInfo;
    }

    public static void setUserAuthInfo(UserAuthInfo mUserAuthInfo) {
        MyApplication.mUserAuthInfo = mUserAuthInfo;
    }

    public static Context getAppContext() {
        return context;
    }

    public static String getBalance() {
        return mBalance;
    }

    public static void setBalance(String balance) {
        MyApplication.mBalance = balance;
    }
}
